Skip to content

feat: Add Visual World Model (VWM) with 4D Gaussian splatting#155

Open
ruvnet wants to merge 733 commits into
mainfrom
claude/visual-world-model-design-BqplZ
Open

feat: Add Visual World Model (VWM) with 4D Gaussian splatting#155
ruvnet wants to merge 733 commits into
mainfrom
claude/visual-world-model-design-BqplZ

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented Feb 8, 2026

Implements ADR-018: Visual World Model as a Bounded Nervous System.

Core crate (ruvector-vwm):

  • 4D Gaussian primitives with temporal deformation and screen projection
  • Spacetime tile system with quantization tiers (Hot8/Warm7/Warm5/Cold3)
  • Packed draw list protocol for deterministic GPU rendering
  • Coherence gate for update acceptance/rejection with rollback support
  • Append-only lineage log with full provenance tracking
  • Entity graph for objects, tracks, regions with typed edges
  • Streaming protocol with keyframe/delta/semantic packets and bandwidth budget

WASM bindings (ruvector-vwm-wasm):

  • Browser-ready wasm-bindgen wrappers for all core types
  • WasmGaussian4D, WasmDrawList, WasmCoherenceGate, WasmEntityGraph
  • WasmLineageLog, WasmActiveMask, WasmBandwidthBudget

WebGPU viewer (examples/vwm-viewer):

  • WGSL shaders for Gaussian splatting with alpha blending
  • CPU-side projection, depth sorting, and active mask filtering
  • Orbit camera controls
  • Synthetic demo data generator
  • Time scrubber UI with FPS counter and entity search

Zero external dependencies in core crate for full WASM compatibility.
Both crates compile cleanly against the workspace.

https://claude.ai/code/session_012MQauGiqSnQbszfmFKpsNT

ruvnet and others added 30 commits December 31, 2025 00:28
…d attention

- Add IntelligenceEngine class integrating VectorDB, SONA, and Attention
- Add 11 new MCP tools (22 total): trajectory tracking, co-edit patterns,
  error suggestions, swarm recommendations, force learning
- Add 8 new CLI commands: trajectory-begin/step/end, coedit-record/suggest,
  error-record/suggest, force-learn
- Integrate Flash/MultiHead attention for embeddings with fallbacks
- Add Read/Glob/Task hooks to settings.json for pattern learning
- Fix @ruvector/attention-linux-x64-gnu (publish v0.1.3)
- Published ruvector@0.1.53

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
feat(hooks): Full IntelligenceEngine with MCP tools, trajectory tracking, and attention
  Built from commit 23fc783

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Add complete integration examples for all 20+ @neural-trader npm packages
with the RuVector platform:

Core Integration:
- basic-integration.js: HNSW vector indexing with trading operations
- hnsw-vector-search.js: Pattern matching with 150x faster native search
- technical-indicators.js: 150+ indicators (RSI, MACD, Bollinger, etc.)

Strategy & Portfolio:
- backtesting.js: Walk-forward optimization, Monte Carlo simulation
- optimization.js: Markowitz, Risk Parity, Black-Litterman portfolios

Neural Networks:
- training.js: LSTM training for price prediction with RuVector storage

Risk Management:
- risk-metrics.js: VaR, CVaR, stress testing, position limits

MCP Integration:
- mcp-server.js: 87+ trading tools via Model Context Protocol

Accounting:
- crypto-tax.js: FIFO/LIFO/HIFO cost basis with native Rust bindings

Specialized Markets:
- sports-betting.js: Arbitrage detection, Kelly criterion sizing
- prediction-markets.js: Polymarket/Kalshi expected value analysis
- news-trading.js: Sentiment-driven event trading

Full Platform:
- platform.js: Complete trading system integration demo

Packages integrated:
- neural-trader@2.7.1 (core engine, 178 NAPI functions)
- @neural-trader/core, strategies, execution, portfolio, risk
- @neural-trader/neural, features, backtesting, market-data
- @neural-trader/mcp, brokers, predictor, backend
- @neural-trader/agentic-accounting-rust-core
- @neural-trader/sports-betting, prediction-markets, news-trading
- @ruvector/core for HNSW vector database
Advanced examples (production-grade):
- live-broker-alpaca.js: Production broker integration with smart order routing
- order-book-microstructure.js: VPIN, Kyle's Lambda, spread decomposition
- conformal-prediction.js: Distribution-free guaranteed prediction intervals

Exotic examples (cutting-edge techniques):
- multi-agent-swarm.js: Distributed trading with consensus mechanisms
- gnn-correlation-network.js: Graph neural network correlation analysis
- attention-regime-detection.js: Transformer attention for regime detection
- reinforcement-learning-agent.js: Deep Q-Learning trading agent
- quantum-portfolio-optimization.js: QAOA and quantum annealing
- hyperbolic-embeddings.js: Poincaré disk market embeddings
- atomic-arbitrage.js: Cross-exchange atomic arbitrage with MEV protection

Updated package.json with npm scripts for all new examples.
Updated README.md with documentation for advanced/exotic techniques.
Key fixes across exotic neural-trader examples:

- reinforcement-learning-agent.js: Fixed broken backpropagation that only
  updated output layer. Now stores activations and flows gradients through
  all hidden layers properly.

- quantum-portfolio-optimization.js: Fixed QAOA mixer Hamiltonian that was
  incorrectly accumulating all qubit operations. Now applies Rx rotations
  sequentially per-qubit with proper normalization.

- hyperbolic-embeddings.js: Fixed Math.acosh/atanh domain errors and
  implemented proper Riemannian gradient descent using expMap in Poincaré
  ball model.

- multi-agent-swarm.js: Added division-by-zero guards for linear regression,
  z-score calculation, and iterator type fixes. Added memory bounds.

- gnn-correlation-network.js: Added guards for betweenness normalization
  (n<3), density (n<2), and clustering/degree calculations (n=0).

- attention-regime-detection.js: Added empty array handling for softmax and
  matrix validation for transpose operations.

- atomic-arbitrage.js: Added guard for flash loan spread calculation.
Generated during deep review of exotic neural-trader examples.
The download logic would immediately fail if model.onnx wasn't at the
repo root, never trying the onnx/ subfolder where most sentence-transformer
models store their ONNX files.

Now tries both locations:
1. Root: {repo}/model.onnx
2. Subfolder: {repo}/onnx/model.onnx

Also applies fallback logic to auxiliary files (tokenizer.json, config.json).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed invalid category "machine-learning" to "algorithms".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New optional companion package using Tract for inference:
- Runs in browsers, Cloudflare Workers, Deno, edge environments
- Same API as native crate
- JavaScript bindings via wasm-bindgen
- Supports all pooling strategies (Mean, Cls, Max, etc.)

Uses Tract instead of ONNX Runtime for WASM compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ples

- gnn-correlation-network.js: Added RollingStats class for O(1) incremental
  updates and correlation caching with TTL to avoid redundant O(n²) calculations

- attention-regime-detection.js: Optimized matmul with cache-friendly i-k-j
  loop order and added empty matrix guards

- quantum-portfolio-optimization.js: Added ComplexPool for object reuse to
  reduce GC pressure, plus in-place operations (addInPlace, multiplyInPlace,
  scaleInPlace) to avoid allocations in hot loops

- multi-agent-swarm.js: Added RingBuffer for O(1) bounded memory operations
  and SignalPool for signal object reuse
Validates core WASM bindings work:
- Version check
- Cosine similarity utility
- L2 normalization utility
- Config creation and chaining

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes PreToolUse:Read hook error by supporting --silent flag
for Read/Glob/Task hooks that should not produce output.

Published ruvector@0.1.54

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds loader.js with:
- Pre-configured model URLs for 6 popular models
- ModelLoader class with caching and progress reporting
- createEmbedder() helper for quick setup
- embed() and similarity() one-liner helpers

Supported models:
- all-MiniLM-L6-v2 (default)
- all-MiniLM-L12-v2
- bge-small-en-v1.5
- bge-base-en-v1.5
- e5-small-v2
- gte-small

Usage:
```javascript
import { createEmbedder } from './loader.js';
const embedder = await createEmbedder('all-MiniLM-L6-v2');
const embedding = embedder.embedOne("Hello world");
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added npm and crates.io version badges
- WebAssembly and MIT license badges
- Quick start examples for Browser, Node.js, and Cloudflare Workers
- Complete API reference for WasmEmbedder, WasmEmbedderConfig
- Model comparison table with 6 HuggingFace models
- Performance benchmarks and use case examples

Published to npm as ruvector-onnx-embeddings-wasm@0.1.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Enable WASM SIMD128 instructions for vectorized operations
- Update simd_available() to properly detect SIMD at compile time
- SIMD build is 180KB smaller than non-SIMD (more compact instructions)
- Published v0.1.1 to both npm and crates.io

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ParallelEmbedder class using Node.js worker_threads
- Distributes batches across multiple CPU cores
- Benchmark results: 3.6-3.8x speedup on batch processing
- Per-text latency drops from ~390ms to ~103ms with 4 workers
- Published v0.1.2 to npm and crates.io

Usage:
  import { ParallelEmbedder } from 'ruvector-onnx-embeddings-wasm/parallel';
  const embedder = new ParallelEmbedder({ numWorkers: 4 });
  await embedder.init();
  const embeddings = await embedder.embedBatch(texts);

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added SIMD badge and documentation
- Added ParallelEmbedder API reference and usage examples
- Updated performance benchmarks with parallel vs sequential comparison
- Added browser compatibility table
- Added changelog section
- Added batch processing use case example
- Updated build instructions with SIMD flags

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New features in this release:
- 13 new CLI hooks commands (AST, Diff, Coverage, Graph, Security, RAG)
- 16 new MCP tools for Claude Code integration
- Enhanced hooks init with v2.0 templates
- 9-phase pretrain with attention/GNN capabilities
- Comprehensive CLAUDE.md documentation generation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… Coverage modules

Core Modules Added:
- ast-parser.ts: Full AST parsing with symbol extraction, complexity analysis
- onnx-embedder.ts: ONNX WASM embeddings with SIMD acceleration
- diff-embeddings.ts: Semantic diff analysis with risk scoring
- coverage-router.ts: Test coverage-aware agent routing
- graph-algorithms.ts: MinCut, Spectral clustering, Louvain communities
- graph-wrapper.ts: Code dependency graph builder
- cluster-wrapper.ts: RuVector cluster management
- router-wrapper.ts: Semantic routing wrapper
- parallel-intelligence.ts: Parallel processing orchestration
- parallel-workers.ts: Worker pool with work stealing

CLI Hooks (13 new commands):
- ast-analyze, ast-complexity
- diff-analyze, diff-classify, diff-similar
- coverage-route, coverage-suggest
- graph-mincut, graph-cluster
- security-scan, rag-context, git-churn, route-enhanced

MCP Server (16 new tools):
- hooks_ast_*, hooks_diff_*, hooks_coverage_*
- hooks_graph_*, hooks_security_*, hooks_rag_*
- hooks_attention_info, hooks_gnn_info

Enhanced Features:
- 10 attention mechanisms (Flash, Hyperbolic, MoE, GraphRoPe, etc.)
- 9-phase pretrain with neural capabilities
- ONNX WASM runtime (7.4MB) with all-MiniLM-L6-v2 support
- hooks init generates v2.0 templates with full documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Claude Code Intelligence v2.0 section with MCP tools
- Add ONNX WASM embeddings documentation
- Add Windows installation with --ignore-scripts
- Add new CLI commands (AST, Diff, Coverage, Graph, Security, RAG)
- Update hooks configuration with new env variables
- Add performance comparison table (40,000x cache speedup)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added benchmark.js performance suite measuring:
- GNN correlation matrix construction
- Matrix multiplication (original vs optimized)
- Object pooling vs direct allocation
- Ring buffer vs Array.shift()
- Softmax function performance

Additional optimizations:
- attention-regime-detection.js: Optimized softmax avoids spread operator,
  uses loop-based max finding and single-pass exp+sum (2x speedup)
- gnn-correlation-network.js: Pre-computed statistics for Pearson correlation
  via precomputeStats() and calculateCorrelationFast() methods. Avoids
  recomputing mean/std for each pair. Spearman rank also optimized.

Benchmark results:
- Cache-friendly matmul: 1.7-2.9x speedup
- Object pooling: 2.7x speedup
- Ring buffer: 12-14x speedup
- Optimized softmax: 2x speedup
- Add Fractional Kelly engine (1/5th Kelly, 576K ops/s)
- Add Hybrid LSTM-Transformer predictor (1.8K predictions/s)
- Add DRL Portfolio Manager (PPO/SAC/A2C ensemble, 17K ops/s)
- Add Sentiment Alpha pipeline (3.7K signals/s)
- Add comprehensive benchmark suite and documentation

All modules production-ready with sub-millisecond latency.
- LSTM: pre-allocate gate vectors, inline sigmoid/tanh (avoid map/reduce)
- MultiHeadAttention: cache-friendly i-k-j matmul, optimized softmax
- FeedForward: pre-allocate hidden layer, manual loops
- LayerNorm: manual mean/variance computation
- Lexicon: char-based word extraction (avoid regex)

Key improvements:
- Buffer push: 1.1M/s (+67%)
- Buffer sample: 319K/s (+22%)
- Lexicon: 346K/s (+16%)
TensorCompress:
- Adaptive tensor compression with 5 levels (none, half, pq8, pq4, binary)
- Access-frequency based auto-compression
- Up to 10x memory savings for pattern storage
- CLI: compress, compress-stats, compress-store, compress-get
- MCP: hooks_compress, hooks_compress_stats, hooks_compress_store, hooks_compress_get

LearningEngine (9 algorithms):
- Q-Learning: Simple off-policy (default)
- SARSA: On-policy, conservative (error-avoidance)
- Double Q-Learning: Reduces overestimation (precise routing)
- Actor-Critic: Policy gradient + value (confidence scoring)
- PPO: Stable policy updates (preference learning)
- Decision Transformer: Sequence modeling (trajectory patterns)
- Monte Carlo: Full episode learning (unbiased estimates)
- TD(λ): Eligibility traces (credit assignment)
- DQN: Experience replay (high-dim states)

CLI Commands:
- learning-config: Configure algorithms per task
- learning-stats: View algorithm performance
- learning-update: Record experiences
- learn: Combined action + recommendation

MCP Tools:
- hooks_learning_config, hooks_learning_stats
- hooks_learning_update, hooks_learn
- hooks_algorithms_list

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add defensive check for this.data.stats
- Initialize with defaults if missing
- Fixes "Cannot read properties of undefined (reading 'last_session')"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Check this.data exists before accessing properties
- Initialize trajectories array if missing
- Add try/catch around engine and save operations
- Null-check trajectory objects in filter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ess (v0.1.69)

## Multi-Algorithm Learning Engine
- 9 algorithms: q-learning, sarsa, double-q, actor-critic, ppo, decision-transformer, monte-carlo, td-lambda, dqn
- Task-specific configuration:
  - agent-routing: double-q (reduces bias)
  - error-avoidance: sarsa (conservative)
  - confidence-scoring: actor-critic (continuous)
  - trajectory-learning: decision-transformer (sequence)
  - context-ranking: ppo (stable)
  - memory-recall: td-lambda (traces)

## TensorCompress (10x Memory Savings)
- 5 compression levels based on access frequency:
  - none (hot >0.8): 0% savings
  - half (warm >0.4): 50% savings
  - pq8 (cool >0.1): 87.5% savings
  - pq4 (cold >0.01): 93.75% savings
  - binary (archive ≤0.01): 96.9% savings
- Auto-compression on session-end

## Pretrain Phases (11 total)
- Phase 10: Multi-algorithm learning bootstrap
- Phase 11: TensorCompress initialization

## Environment Variables (v2.1)
- RUVECTOR_MULTI_ALGORITHM=true
- RUVECTOR_DEFAULT_ALGORITHM=double-q
- RUVECTOR_TENSOR_COMPRESS=true
- RUVECTOR_AUTO_COMPRESS=true

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add null checks in getQ() method for patterns object
- Add null checks in updateQ() and learn() methods
- Improve load() to merge file data with defaults
- Ensures all required fields exist even with partial data
- Fixes 'Cannot read properties of undefined' errors

Published as v0.1.70
New CLI Commands:
- batch-learn: Process multiple learning experiences at once
- subscribe: Stream real-time learning updates (polling)
- watch: Auto-learn from file changes in real-time

New MCP Tools (49 total):
- hooks_batch_learn: Batch process experiences array
- hooks_subscribe_snapshot: Get state deltas for subscriptions
- hooks_watch_status: Get current watch/learning status

Features:
- Batch learning processes multiple experiences efficiently
- Subscribe streams events: learn, route, memory, compress
- Watch monitors file changes and auto-learns patterns
- Co-edit detection in watch mode (files edited within 1 min)

Published as v0.1.71
ruvnet and others added 28 commits January 28, 2026 03:51
- Add GoogleAIProvider for direct Gemini API access
- Support Gemini 2.5 Flash, Pro, and Lite models
- Add Gemini 3.x preview models
- Auto-detect and use Google AI when GOOGLE_AI_API_KEY is set
- Update chat UI with debugging and LLM status checks
- Fix model routing for Google Cloud deployments
- Bump version to 0.1.8

Tested models:
- gemini-2.5-flash (stable, recommended)
- gemini-2.5-pro (stable)
- gemini-2.5-flash-lite (stable)

Sources:
- https://ai.google.dev/gemini-api/docs/models

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements the full delta-behavior framework - systems where change is
permitted but collapse is not.

## Core Implementation
- Coherence type with [0,1] bounds and safe constructors
- Three-layer enforcement: energy cost, scheduling, memory gating
- DeltaSystem trait for coherence-preserving systems
- DeltaConfig with strict/relaxed/default presets

## 11 Exotic Applications
1. Self-Limiting Reasoning - AI that does less when uncertain
2. Computational Event Horizon - bounded computation without hard limits
3. Artificial Homeostasis - synthetic life with coherence-based survival
4. Self-Stabilizing World Model - models that refuse to hallucinate
5. Coherence-Bounded Creativity - novelty without chaos
6. Anti-Cascade Financial System - markets that cannot collapse
7. Graceful Aging - systems that simplify over time
8. Swarm Intelligence - collective behavior without pathology
9. Graceful Shutdown - systems that seek safe termination
10. Pre-AGI Containment - bounded intelligence growth
11. Extropic Substrate - goal mutation, agent lifecycles, spike semantics

## Performance Optimizations
- O(n²) → O(n·k) swarm neighbor detection via SpatialGrid
- O(n) → O(1) coherence calculation with incremental cache
- VecDeque for O(1) history removal
- SIMD utilities with 8x loop unrolling
- Bounded history to prevent memory leaks

## Security Fixes
- Replaced unsafe static mut with AtomicU64 for thread-safe RNG
- NaN validation on all coherence inputs
- Overflow protection in calculations

## WASM + TypeScript SDK
- Full wasm-bindgen exports for all 11 applications
- High-level TypeScript SDK with ergonomic APIs
- Browser and Node.js examples

## Test Coverage
- 32 lib tests, 14 WASM tests, 13 doc tests (59 total)

Resolves #140

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds modular crates implementing delta-behavior for different domains:

## ruvector-delta-core
- Delta trait with compute/apply/compose/inverse operations
- VectorDelta with sparse/dense encoding
- DeltaStream for event sourcing with checkpoints
- DeltaWindow for time-bounded aggregation
- Compression codecs: LZ4, Zstd, DeltaOfDelta, Quantized

## ruvector-delta-wasm
- JsDelta JavaScript-friendly wrapper
- DeltaEngine for capture/apply operations
- SIMD-accelerated operations
- SharedBuffer and BufferPool for memory management

## ruvector-delta-index
- DeltaHnsw - delta-aware HNSW index
- IncrementalUpdater with multiple strategies
- GraphRepairer with lazy/eager/batched/adaptive modes
- QualityMonitor for recall estimation

## ruvector-delta-graph
- GraphDelta for node/edge operations
- NodeDelta with property and label changes
- EdgeDelta with weight and type changes
- DeltaAwareTraversal (BFS, DFS, shortest path)

## ruvector-delta-consensus
- VectorClock and HybridLogicalClock
- DeltaConsensus coordinator
- DeltaGossip for delta dissemination
- CRDTs: GCounter, PNCounter, LWWRegister, ORSet

Test coverage: 77+ tests across all crates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ChatEnhancer for enhanced chat processing with skills, memory,
  and proactive assistance integration
- Add SkillExecutor for skill lifecycle management and execution
- Add builtin skills: CodeSkill, MemorySkill, SummarizeSkill, WebSearchSkill
- Improve server.ts with better error handling and session management
- Update AIDefenceGuard with enhanced security checks
- Update chat UI with improved styling and interactions
- Bump version to 0.1.1 with delta crates integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
feat(ruvbot): v0.1.1 with skill system, chat UI, and delta crates
  Built from commit 048b8e5

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
This commit fixes a critical P0 bug where HNSW indexes on ruvector
columns would crash PostgreSQL with a segmentation fault when using
parameterized queries (prepared statements, ORMs, application drivers).

Root Cause:
- Query vector extraction failed for parameterized queries
- Code fell back to zero vector without validation
- Zero vector caused segfault during HNSW search

Changes:
- Add multi-method query vector extraction pipeline
  1. Direct RuVector::from_polymorphic_datum()
  2. Text parameter conversion for parameterized queries
  3. Validated varlena fallback with dimension checking
- Add query_valid flag to track extraction success
- Add validation before search execution:
  - Reject empty/invalid query vectors with clear errors
  - Reject all-zero vectors (invalid for similarity search)
  - Validate dimension match between query and index
- Apply same fixes to IVFFlat for consistency

Testing:
- Added regression tests for parameterized queries
- Added tests for zero vector error handling
- Added tests for dimension mismatch errors
- Added 384-dimension production-scale tests

Fixes: #141
See: docs/adr/ADR-0027-hnsw-parameterized-query-fix.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move datum and false arguments to same line in from_polymorphic_datum
- Join split let text_len = ... assignment to single line

These changes fix CI rustfmt check failures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Run rustfmt on all Rust files to fix CI formatting checks.
This addresses pre-existing formatting inconsistencies across:
- cognitum-gate-kernel
- cognitum-gate-tilezero
- prime-radiant
- ruvector-* crates
- examples/benchmarks
- and other crates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ault-141

fix(hnsw): resolve segfault with parameterized queries (#141)
  Built from commit e76f01a

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Resolves the "already exists and is not an empty directory" error by:
- Adding a cleanup step to remove the directory before git clone
- Setting up Node.js for ruvector dependencies
- Installing and verifying ruvector MCP installation
  Built from commit 1eb32f7

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Implements the 6-stage CRV (Coordinate Remote Viewing) signal line
methodology as a ruvector subsystem, mapping each stage to the
appropriate vector database component:

- Stage I: Ideogram gestalts → Poincaré ball hyperbolic embeddings
  (ruvector-attention), encoding hierarchical gestalt taxonomy
- Stage II: Sensory impressions → Multi-head attention vectors
  (ruvector-attention), one head per sensory modality
- Stage III: Dimensional sketches → GNN graph topology
  (ruvector-gnn), spatial elements as nodes, relationships as edges
- Stage IV: Emotional/AOL data → SNN temporal encoding
  (ruvector-mincut SNN), spike rate analysis for AOL detection
- Stage V: Signal line interrogation → Differentiable search
  (ruvector-gnn), soft attention over accumulated session data
- Stage VI: Composite modeling → MinCut partitioning
  (ruvector-mincut), cluster boundary detection for target aspects

Includes session manager with DAG structure, cross-session convergence
analysis for multi-viewer target matching, and 40 passing unit tests.

https://claude.ai/code/session_01CESp4koS81HfLK1HEyCmKJ
  Built from commit 5147a27

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Introduces a complete temporal tensor compression system with:

- ADR-017: SOTA research-backed architecture decision record covering
  groupwise symmetric quantization, temporal segment reuse, access-pattern
  driven tier selection (8/7/5/3 bit), and WASM-compatible design

- ruvector-temporal-tensor crate (zero external dependencies):
  - tier_policy: Score-based hot/warm/cold bit-width selection
  - f16: Software IEEE 754 half-precision conversion
  - bitpack: Arbitrary bit-width stream packing (no alignment waste)
  - quantizer: Groupwise symmetric quantization with f16 scales
  - segment: Binary segment format (TQTC) encode/decode
  - compressor: Temporal segment manager with drift detection
  - ffi: WASM/C FFI with handle-based resource management

- ruvector-temporal-tensor-wasm crate for wasm32 targets

- 33 passing unit tests covering all modules

Compression targets: 4x (hot/8-bit), 4.57x (warm/7-bit),
6.4x (warm/5-bit), 10.67x (cold/3-bit) vs f32 baseline.

https://claude.ai/code/session_01U63xtGd5Q8mUevyY7nUSfJ
Key optimizations:
- Eliminate per-value modulo/division in dequantize by restructuring
  to iterate by frame→group→element (was: flat index with val_idx % tensor_len)
- Cache f32 scales in TemporalTensorCompressor to avoid repeated f16→f32
  conversion on every push_frame (drift check + quantization)
- Add optimized _f32 API variants (frame_fits_scales_f32, quantize_and_pack_f32,
  dequantize_f32) that accept pre-converted scales
- Pre-reserve Vec capacity in quantize_and_pack (avoids reallocations)
- Add #[inline] on qmax_from_bits, f32_to_f16_bits, f16_bits_to_f32
- Use chunks() iterator instead of manual index tracking in compute_scales

New tests (41 total, up from 33):
- Roundtrip tests for 5-bit and 7-bit quantization
- Non-finite value handling (NaN, Inf, -Inf)
- Single-element group edge case
- Compression ratio validation for all tiers
- Cold-tier (3-bit) full roundtrip
- Large tensor multi-group (512-dim, 50 frames)
- Accessor method coverage

https://claude.ai/code/session_01U63xtGd5Q8mUevyY7nUSfJ
…ties

- Fix all clippy warnings: module-level //! docs, .div_ceil(), is_empty()
- Optimize segment::decode to call dequantize_f32 directly (skip legacy wrapper)
- Add decode_single_frame() for random-access frame decoding
- Add compression_ratio() utility for segment inspection
- Add comprehensive doc-examples with 3 tested examples in lib.rs
- Fix HEADER_SIZE offset bug in decode_single_frame (22 vs 26)
- All 41 unit tests + 3 doc-tests pass, 0 clippy warnings

https://claude.ai/code/session_01U63xtGd5Q8mUevyY7nUSfJ
Plain-language introduction explaining what temporal tensor compression
does and why it matters, feature tables, Quick Start with 4 code
examples (basic, streaming, random-access, custom policy), full API
reference, segment binary format spec, FFI/WASM guide, and build
instructions.

https://claude.ai/code/session_01U63xtGd5Q8mUevyY7nUSfJ
  Built from commit ddb0408

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Implements ADR-018: Visual World Model as a Bounded Nervous System.

Core crate (ruvector-vwm):
- 4D Gaussian primitives with temporal deformation and screen projection
- Spacetime tile system with quantization tiers (Hot8/Warm7/Warm5/Cold3)
- Packed draw list protocol for deterministic GPU rendering
- Coherence gate for update acceptance/rejection with rollback support
- Append-only lineage log with full provenance tracking
- Entity graph for objects, tracks, regions with typed edges
- Streaming protocol with keyframe/delta/semantic packets and bandwidth budget

WASM bindings (ruvector-vwm-wasm):
- Browser-ready wasm-bindgen wrappers for all core types
- WasmGaussian4D, WasmDrawList, WasmCoherenceGate, WasmEntityGraph
- WasmLineageLog, WasmActiveMask, WasmBandwidthBudget

WebGPU viewer (examples/vwm-viewer):
- WGSL shaders for Gaussian splatting with alpha blending
- CPU-side projection, depth sorting, and active mask filtering
- Orbit camera controls
- Synthetic demo data generator
- Time scrubber UI with FPS counter and entity search

Zero external dependencies in core crate for full WASM compatibility.
Both crates compile cleanly against the workspace.

https://claude.ai/code/session_012MQauGiqSnQbszfmFKpsNT
…r VWM

Documentation:
- README for ruvector-vwm (712 lines) with collapsible groups covering
  all core concepts, 13 use cases across product/research/frontier tiers,
  architecture diagrams, and quick start examples
- README for ruvector-vwm-wasm with full API reference, JS examples,
  and type mapping tables
- README for vwm-viewer with quick start, controls, and WebGPU pipeline docs

Architecture Decision Records:
- ADR-019: Three-Cadence Loop Architecture (fast/medium/slow rate separation)
- ADR-020: GNN-to-Coherence-Gate Feedback Pipeline (identity verdicts,
  mincut signal, confidence calibration)
- ADR-021: Four-Level Attention Architecture (view/temporal/semantic/write)
- ADR-022: Query-First Rendering Pattern (retrieve → select → render)

Integration Tests:
- 28 end-to-end tests covering full pipeline, dynamic scenes, coherence
  gate scenarios, entity graph warehouse scene, lineage audit trail,
  streaming protocol, multi-tile scenes, privacy tags, roundtrip fidelity,
  and edge cases

All 78 tests pass (49 unit + 28 integration + 1 doc-test).

https://claude.ai/code/session_012MQauGiqSnQbszfmFKpsNT
…ks, and embedding search

- Add four-level attention pipeline (view/temporal/semantic/write) per ADR-021
- Add query-first rendering engine with SceneQuery/QueryResult per ADR-022
- Add three-cadence loop scheduler (fast 60Hz, medium 5Hz, slow 0.5Hz) per ADR-019
- Add static/dynamic layer separation with automatic Gaussian classification
- Add cosine-similarity embedding search (search_by_embedding, top_k_by_embedding) to EntityGraph
- Add Criterion benchmark suite (20 benchmarks across 8 groups: gaussian, tile, draw_list, coherence, entity, mask, streaming, sort)
- Add performance acceptance tests
- Implement WASM integration path in viewer (coherence gate, entity graph, active mask, draw list)
- 177 tests passing, clippy clean, zero dependencies in core crate

https://claude.ai/code/session_012MQauGiqSnQbszfmFKpsNT
Integration tests now use tolerance-based comparison for float fields
since PrimitiveBlock::encode uses real 8-bit quantization (lossy).
IDs remain exact. All 28 integration tests pass.

https://claude.ai/code/session_012MQauGiqSnQbszfmFKpsNT
Copy link
Copy Markdown
Owner Author

@ruvnet ruvnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: Visual World Model (VWM) — PR #155

Scope: 35 new files, 12,738 additions across core Rust crate, WASM bindings, 5 ADRs, WebGPU viewer example.

Build: Compiles cleanly. All CI checks pass (5 platforms). All 169 tests pass (130 unit, 28 integration, 10 acceptance, 1 doc-test).


Architecture Assessment

The five ADRs (018-022) form a clean dependency chain: ADR-018 (foundation) → ADR-019 (loop cadences) → ADR-020 (GNN feedback) → ADR-021 (attention levels) → ADR-022 (query-first rendering). The implementation faithfully represents the three-loop architecture, 4D Gaussian primitives, packed draw list protocol, and coherence gate. Zero runtime dependencies in the core crate — excellent for WASM compatibility.

Strong points: Explicit invariants ("the world model is the source of truth; the splats are a view of it"), concrete latency budgets (12ms fast/500ms medium/10s slow), graceful degradation design, no unsafe code anywhere.


Blocking Issues (3)

B1. Incorrect Jacobian cross-term in Gaussian projection (gaussian.rs:170-178)
The 2D covariance cross-term cov2d_b is computed twice with different formulations then averaged. This does not correspond to any correct derivation of J * Σ * J^T. The two formulations give different results because they use different rows of the intermediate product. The correct answer is one or the other, not the average. The let _ = t3; and let _ = cov2d_b; suppressing unused-variable warnings confirm the author knew these values were suspicious. This produces incorrect screen-space Gaussian shapes.

B2. Panic risk in decode_quantized() (tile.rs:382-438)
No bounds checks on self.data before array indexing. Since PrimitiveBlock and its data field are both pub, external code can construct blocks with truncated/corrupted data and trigger panics. The decode_raw() path has a length guard but decode_quantized() does not.

B3. bindTile/drawBlock string-as-u32 bug in viewer (examples/vwm-viewer/src/main.js:262,267)

drawList.bindTile(0, 'main-block', 0);  // 'main-block' → u32 = NaN → 0
drawList.drawBlock('main-block', animTime, activeCount > 0 ? 0 : 1);

The Rust binding expects u32 for block_ref. wasm-bindgen coerces the string to NaN0. Works by accident but silently corrupts the draw list data.


Major Issues (6)

M1. Per-frame tile decoding in layer system (layer.rs:157-183)
active_count_at() and dynamic_active_mask_at() call tile.primitive_block.decode() for every dynamic tile on every invocation. At 60Hz this decodes all dynamic Gaussians every frame. Decoded Gaussians should be cached.

M2. queryByType return format mismatch in viewer (main.js:153-161)
WASM returns entity IDs (numbers) but JS expects entity objects with embedding fields. The JSON.parse(entity.embedding || '{}') path always fails silently, making the WASM entity graph search non-functional. It works only because the fallback label substring match covers the same cases.

M3. Coherence gate result not properly mapped in viewer (main.js:233-237)
The gate returns decision strings ("accept"/"defer"/"freeze"/"rollback") but the code treats any truthy string as "coherent". Should be result === 'accept' ? 'coherent' : 'degraded'.

M4. Duplicate FNV implementations with different algorithms (tile.rs:535 vs draw_list.rs:215)
tile.rs uses multiply-then-xor (FNV-1), draw_list.rs uses xor-then-multiply (FNV-1a). Both comments say "FNV" but they are different hash algorithms.

M5. WASM time-range API gap
addObject/addTrack hardcode time_span to [NEG_INFINITY, INFINITY] and addEdge always sets time_range: None. The core crate extensively supports time-range queries (tested in integration tests) but this capability is unreachable from JS.

M6. Missing WASM API surface for core pipeline
The attention, query, layer, runtime, tile modules (ADR-021/022 higher-level orchestration) have no WASM bindings. Without Gaussian4D::project() and ScreenGaussian, the viewer must re-implement projection in JavaScript.


Moderate Issues (8)

# File Issue
1 tile.rs QuantTier::Warm7/Warm5/Cold3 all silently fall back to Hot8 8-bit encoding
2 draw_list.rs No from_bytes() deserialization despite "network transport" documentation
3 entity.rs No edge deduplication; edge_count() counts duplicates
4 entity.rs top_k_by_embedding is O(N log N) — should use heap for O(N log k)
5 attention.rs Frustum culling is point-only (ignores Gaussian spatial extent), causes popping
6 runtime.rs poll() eagerly marks last-tick time before caller confirms execution
7 layer.rs total_gaussians field can drift from actual tile counts (no remove/update)
8 streaming.rs Packet types lack serialization despite "network transport protocol" design

ADR Consistency Notes

  1. ADR-018 defines 4 loops; ADR-019 collapses to 3 — the "prediction loop" has no explicit home in the three-cadence model
  2. ADR-020 vs implementation gap — ADR-020 describes GNN-based calibrated coherence; implementation uses simpler fixed-threshold model (acceptable as Phase 1, but should be noted)
  3. ADR-022 select_active_blocks truncates by block count, not Gaussian count — can exceed the budget since blocks contain variable numbers of Gaussians

Test Quality

Tests are exceptionally well-documented and thorough. Notable gaps:

  • No tests for TileMerged, EntityAdded/EntityUpdated lineage events
  • No test for SameIdentity edge type
  • No lineage benchmarks (append-only log will grow over time)
  • Timing-based acceptance tests could be flaky on slow CI runners
  • WASM js_name inconsistency — some methods are camelCase, others snake_case

Security

  • No unsafe code anywhere — excellent
  • No XSS vectors in the viewer (uses textContent exclusively)
  • Provenance::signature field is never verified — provides no integrity guarantee
  • Nearly all structs have all-public fields — external code can construct invalid states triggering panics in decode paths

Summary

Severity Count
Blocking 3
Major 6
Moderate 8
Minor ~15

The core architecture is sound and well-implemented. The three blocking issues (Jacobian math, decode panic, viewer type bug) should be fixed before merge. The major issues are real but non-blocking — they represent API gaps and viewer bugs that can be addressed in follow-up PRs.

Recommended action: Fix B1-B3, then merge. Track M1-M6 as follow-up issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants